package com.jluzh10.learning.domain;

import com.jluzh10.learning.utils.qiniu.QiniuUtil;

import javax.annotation.PreDestroy;
import java.text.DecimalFormat;
import java.util.Date;

public class Course {
    //课程的讲师信息
    private Teacher teacher;
    //用户是否收藏
    private boolean collect;

    private Integer id;

    private Integer teacherId;

    private String name;

    private String namePinyin;

    private Byte level;

    private Date createTime;

    private Integer hours;

    private Integer minutes;

    private String introduction;

    private String crowd;

    private Double avgScope;

    //小数点后一位的平均评分
    private String avgStr;

    private Double totalScope;

    private Integer scopeNum;

    private Integer classifyId;

    private Integer groupId;

    private String classifyPinyin;

    private String picture;

    private Integer hits;

    private Integer collectionNum;

    private Integer weight;

    private Byte recommend;

    private Byte state;

    public Course(Integer id, Integer hits) {
        this.id = id;
        this.hits = hits;
    }

    public Course() {
    }

    public String getAvgStr() {
        if (scopeNum!=null&&totalScope!=null){
            return new DecimalFormat("#.0").format(totalScope/scopeNum);
        }
        return avgStr;
    }


    public boolean getCollect() {
        return collect;
    }

    public void setCollect(boolean collect) {
        this.collect = collect;
    }

    public Teacher getTeacher() {
        return teacher;
    }

    public void setTeacher(Teacher teacher) {
        this.teacher = teacher;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(Integer teacherId) {
        this.teacherId = teacherId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getNamePinyin() {
        return namePinyin;
    }

    public void setNamePinyin(String namePinyin) {
        this.namePinyin = namePinyin == null ? null : namePinyin.trim();
    }

    public Byte getLevel() {
        return level;
    }

    public void setLevel(Byte level) {
        this.level = level;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getHours() {
        return hours;
    }

    public void setHours(Integer hours) {
        this.hours = hours;
    }

    public Integer getMinutes() {
        return minutes;
    }

    public void setMinutes(Integer minutes) {
        this.minutes = minutes;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction == null ? null : introduction.trim();
    }

    public String getCrowd() {
        return crowd;
    }

    public void setCrowd(String crowd) {
        this.crowd = crowd == null ? null : crowd.trim();
    }

    public Double getAvgScope() {
        return avgScope;
    }

    public void setAvgScope(Double avgScope) {

        this.avgScope = avgScope;
    }

    public Double getTotalScope() {
        return totalScope;
    }

    public void setTotalScope(Double totalScope) {
        this.totalScope = totalScope;
    }

    public Integer getScopeNum() {
        return scopeNum;
    }

    public void setScopeNum(Integer scopeNum) {
        this.scopeNum = scopeNum;
    }

    public Integer getClassifyId() {
        return classifyId;
    }

    public void setClassifyId(Integer classifyId) {
        this.classifyId = classifyId;
    }

    public Integer getGroupId() {
        return groupId;
    }

    public void setGroupId(Integer groupId) {
        this.groupId = groupId;
    }

    public String getClassifyPinyin() {
        return classifyPinyin;
    }

    public void setClassifyPinyin(String classifyPinyin) {
        this.classifyPinyin = classifyPinyin == null ? null : classifyPinyin.trim();
    }

    public String getPicture() {
        if (picture!=null){
            return QiniuUtil.getUrlByCourse(picture);
        }
        return null;
    }

    public void setPicture(String picture) {
        this.picture = picture == null ? null : picture.trim();
    }

    public Integer getHits() {
        return hits;
    }

    public void setHits(Integer hits) {
        this.hits = hits;
    }

    public Integer getCollectionNum() {
        return collectionNum;
    }

    public void setCollectionNum(Integer collectionNum) {
        this.collectionNum = collectionNum;
    }

    public Integer getWeight() {
        return weight;
    }

    public void setWeight(Integer weight) {
        this.weight = weight;
    }

    public Byte getRecommend() {
        return recommend;
    }

    public void setRecommend(Byte recommend) {
        this.recommend = recommend;
    }

    public Byte getState() {
        return state;
    }

    public void setState(Byte state) {
        this.state = state;
    }

    @Override
    public String toString() {
        return "Course{" +
                "collect=" + collect +
                ", id=" + id +
                ", teacherId=" + teacherId +
                ", name='" + name + '\'' +
                ", namePinyin='" + namePinyin + '\'' +
                ", level=" + level +
                ", createTime=" + createTime +
                ", hours=" + hours +
                ", minutes=" + minutes +
                ", introduction='" + introduction + '\'' +
                ", crowd='" + crowd + '\'' +
                ", avgScope=" + avgScope +
                ", totalScope=" + totalScope +
                ", scopeNum=" + scopeNum +
                ", classifyId=" + classifyId +
                ", groupId=" + groupId +
                ", classifyPinyin='" + classifyPinyin + '\'' +
                ", picture='" + picture + '\'' +
                ", hits=" + hits +
                ", collectionNum=" + collectionNum +
                ", weight=" + weight +
                ", recommend=" + recommend +
                ", state=" + state +
                '}';
    }
}